package com.engine.cetc.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.cetc.service.SmartInputService;
import com.engine.cetc.service.impl.SmartInputServiceImpl;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @Title: ecology-idea
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2022-03-22
 * @Description: ${description}
 * @ModifyLog:
 **/
public class WeaSmartInputAction {
    private SmartInputService getService(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
        User user = HrmUserVarify.getUser(httpServletRequest, httpServletResponse);
        return this.getService(user);
    }

    private SmartInputService getService(User user) {
        return (SmartInputServiceImpl) ServiceUtil.getService(SmartInputServiceImpl.class, user);
    }
    @GET
    @Path("/getDetailInfo")
    @Produces({"text/plain;charset=utf-8"})
    public String getDetailInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        Object apidatas = new HashMap();

        try {
            apidatas = this.getService(request, response).getDetailInfo( ParamUtil.request2Map(request));
        } catch (Exception e) {
            e.printStackTrace();
            ((Map)apidatas).put("data", new ArrayList());
            ((Map)apidatas).put("api_status", false);
            ((Map)apidatas).put("api_errormsg", "catch exception : " + e.getMessage());
        }

        return JSONObject.toJSONString(apidatas);
    }
}
